/*
 * FreeModbus Libary: BARE Port
 * Copyright (C) 2006 Christian Walter <wolti@sil.at>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * File: $Id$
 */

#ifndef _PORT_H
#define _PORT_H

#include "cm32m101a.h"
#include <stdint.h>
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>

#include "mbconfig.h"

#include "delay.h"
#include "time.h"
#include "eeprom.h"


#define    INLINE                      inline
#define    PR_BEGIN_EXTERN_C           extern "C" {
#define    PR_END_EXTERN_C             }

#define     ENTER_CRITICAL_SECTION( )   
#define     EXIT_CRITICAL_SECTION( )  

/*beep-PA12*/
#define RS485_Mode_PORT            GPIOA
#define RS485_Mode_PIN             GPIO_PIN_1
                                  
#define MAX485_SetMode(X)    if(X) GPIO_SetBits(RS485_Mode_PORT, RS485_Mode_PIN);\
                              else GPIO_ResetBits(RS485_Mode_PORT, RS485_Mode_PIN)


                              
typedef unsigned char BOOL;

typedef unsigned char UCHAR;
typedef char CHAR;

typedef uint16_t USHORT;
typedef int16_t SHORT;

typedef uint32_t ULONG;
typedef int32_t LONG;

#ifndef MODE_RECV
#define MODE_RECV            0
#endif

#ifndef MODE_SENT
#define MODE_SENT           1
#endif

#ifndef TRUE
#define TRUE            1
#endif

#ifndef FALSE
#define FALSE           0
#endif

#if MB_FUNC_READ_COILS_ENABLED>0||MB_FUNC_WRITE_COIL_ENABLED>0||MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED>0
/*! \brief If the <em> Coils</em> function should be enabled. */
#define MB_FUNC_COIL_ENABLED                1 

#endif

#if MB_FUNC_READ_HOLDING_ENABLED>0||MB_FUNC_WRITE_HOLDING_ENABLED>0||MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED>0
/*! \brief If the <em> Coils</em> function should be enabled. */
#define MB_FUNC_HOLDING_ENABLED                1 

#endif

#endif
